import Taro from "@tarojs/taro"


const baseUrl = 'https://www.fastmock.site/mock/6824ec91899a3dacea48facf0994b4f8/pencher'
const baseUrl_ = 'https://api.binstd.com/recipe'
const baseUrl__ = 'http://127.0.0.1:3007'

export default function requst(api, type, url, obj) {
    // eslint-disable-next-line no-unused-vars
    var base
    switch (api) {
        case 1:
            base = baseUrl
            break;
        case 2:
            base = baseUrl_
            break;
        default:
            base = baseUrl__
            break;
    }
    return new Promise((resolve, reject) => {

        Taro.request({
            url: base + url,
            method: type,
            data: obj,
            success(res) {
                resolve(res.data.data || res)
            },
            fail(res) {
                reject(res)
            }
        })
    })

    /*  */
}